package website.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import website.advice.BaseResponse;
import website.domain.Message;
import website.domain.ResModel;
import website.domain.User;
import website.service.MessageService;


@Api("留言控制类")
@BaseResponse
@RestController
@RequestMapping("/api/message")
public class MessageController {

    @Autowired
    private MessageService messageService;

    @ApiOperation("发布留言")
    @PostMapping(path = "",produces = "application/json")
    public ResModel issue(@RequestBody Message message){
        return messageService.issue(message);
    }

    @ApiOperation("查询留言")
    @GetMapping
    public ResModel list(){
        return messageService.getList();
    }

    @ApiOperation("分页查询留言信息")
    @GetMapping("/{current}/{size}")
    public ResModel<IPage<Message>> list(@PathVariable Integer current, @PathVariable Integer size){
        return messageService.getByPage(current,size);
    }

    @ApiOperation("删除留言信息")
    @DeleteMapping("/{id}")
    public ResModel delMsg(@PathVariable Integer id){
        return messageService.delMsg(id);
    }
}
